﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CommonPageMenuContent.ascx.cs" Inherits="admin_webparts_Plug_ins_CommonPage_CommonPageMenuContent" %>
<%@ Import Namespace="NTTHAO.CommonWeb" %>
<%@ Import Namespace="NTTHAO.Common.BL" %>
<%@ Import Namespace="NTTHAO.Web.BL.CommonPage" %>
<script type="text/javascript">
    function showHideDetail(o) {
        if (YAHOO.util.Dom.getStyle('tbTypeDetail', 'display') == 'table') {
            YAHOO.util.Dom.setStyle('tbTypeDetail', 'display', 'none'); 
            o.innerText = '<%=LanguageUtility.GetLanguageText("DETAIL", Session)%>';
            YAHOO.util.Dom.removeClass(o.parentNode.parentNode, 'collapse');
            YAHOO.util.Dom.addClass(o.parentNode.parentNode, 'expand');
        } else {
            YAHOO.util.Dom.setStyle('tbTypeDetail', 'display', 'table'); 
            o.innerText = '<%=LanguageUtility.GetLanguageText("HIDE_DETAIL", Session)%>';
            YAHOO.util.Dom.removeClass(o.parentNode.parentNode, 'expand');
            YAHOO.util.Dom.addClass(o.parentNode.parentNode, 'collapse');
        }
        if (typeof onWindowResize == 'function') {
            onWindowResize();
        }
    }
</script>
<div class="tip" style="overflow: hidden;">
    <div style="clear: left; float: left; overflow: hidden;">
        <h2 style="padding-top: 2px;"><%=this._SelectedMenu == null ? LanguageUtility.GetLanguageText("COMMON_CONTENT") : this._SelectedMenu.Text%>
        </h2>
    </div>
    <div style="float: right; width: 450px;">
        <div style="text-align: right;"><%
        if (this._SelectedMenu != null || this._IsAdminLogged) { %>
            <span id="spTypeManage" class="yui-button yui-link-button yuibtn yuibtn-icon btnmanage"><span class="first-child"><a href="?action=manmenu&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this._SelectedMenu != null ? this._SelectedMenu.ID : 0 %>"><%=LanguageUtility.GetLanguageText("MANAGE_SUB_NEMU", Session)%></a></span></span><%
        } 
        if ((this._SelectedMenu != null && (_SelectedMenu.LinkType == 0 || _SelectedMenu.LinkType == 1)) || this._IsAdminLogged) { %>
            <span id="spLinkAdd" class="yui-button yui-link-button yuibtn yuibtn-icon btnaddf"><span class="first-child"><a href="?action=addmnu&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>"><%=LanguageUtility.GetLanguageText("ADD_SUB_MENU", Session)%></a></span></span><%
        } 
        if (this._SelectedMenu != null) 
        { 
            if(_SelectedMenu.LinkType != 1) 
            { %>
            <span id="spLinkAddContent" class="yui-button yui-link-button yuibtn yuibtn-icon btnaddp"><span class="first-child"><a href="?action=addcontent&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>"><%=LanguageUtility.GetLanguageText("ADD_NEW_CONTENT", Session)%></a></span></span><%
            } 
            else 
            { %>
            <span id="spLinkAddAlbum" class="yui-button yui-link-button yuibtn yuibtn-icon btnaddp"><span class="first-child"><a href="?action=addalbum&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>"><%=LanguageUtility.GetLanguageText("ADD_NEW_CONTENT", Session)%></a></span></span><%
            } 
        } %>
        </div>
        <%
        if (this._SelectedMenu != null) 
        { %>
        <div style="text-align: right; margin-top: 5px;">
            <span id="spLinkView" class="yui-button yui-link-button yuibtn yuibtn-icon expand"><span class="first-child"><a href="javascript: return false;" onclick="javascript: showHideDetail(this); return false;"><%=LanguageUtility.GetLanguageText("DETAIL", Session)%></a></span></span>
        <%
            if (this._SelectedMenu.ParentID > 0 || this._IsAdminLogged) 
            { 
        %>
            <span id="spMoveTo" class="yui-button yui-link-button yuibtn yuibtn-icon btnmove"><span class="first-child"><a href="?action=movemenu&g=<%=this.Request.QueryString["g"] %>&id=<%=this.Request.QueryString["mnuid"] %>"><%=LanguageUtility.GetLanguageText("MOVE", Session)%></a></span></span>
            <span id="spLinkEdit" class="yui-button yui-link-button yuibtn yuibtn-icon btnedit"><span class="first-child"><a href="?action=editmnu&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>"><%=LanguageUtility.GetLanguageText("EDIT", Session)%></a></span></span>
            <span id="spLinkDelete" class="yui-button yui-link-button yuibtn yuibtn-icon btndelete"><span class="first-child"><a href="?action=deletemnu&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>" onclick="javascript: return confirmDelete();"><%=LanguageUtility.GetLanguageText("DELETE", Session)%></a></span></span>
            <%}%>
        </div>  
        <% } %>
    </div>
    <script type="text/javascript">
        YAHOO.util.Event.onContentReady("spLinkDelete", function () {
        <%if (this._SelectedMenu != null || this._IsAdminLogged) { %>
            var spTypeManage = new YAHOO.widget.Button("spTypeManage");
            var oSpLinkAdd = new YAHOO.widget.Button("spLinkAdd");
        <%} %>
        <%if (this._SelectedMenu != null && (this._SelectedMenu.ParentID > 0 || this._IsAdminLogged)) { %>
            var oSpMoveTo = new YAHOO.widget.Button("spMoveTo");
        <%} %>
            var spLinkView = new YAHOO.widget.Button("spLinkView");
            var oSpLinkEdit = new YAHOO.widget.Button("spLinkEdit");
            var oSpLinkDelete = new YAHOO.widget.Button("spLinkDelete");
        });
    <%if(this._SelectedMenu != null && _SelectedMenu.LinkType != 1) { %>
        YAHOO.util.Event.onContentReady("spLinkAddContent", function () {
            var oSpLinkAddContent = new YAHOO.widget.Button("spLinkAddContent");
        });
    <%} else if(this._SelectedMenu != null) { %>
        YAHOO.util.Event.onContentReady("spLinkAddAlbum", function () {
            var oSpLinkAddAlbum = new YAHOO.widget.Button("spLinkAddAlbum");
        });
    <%} %>
    </script>
</div>
<%if (this._SelectedMenu != null) { %>
<table cellspacing="0" cellpadding="3" border="1" class="grid" id="tbTypeDetail" style="display: none;margin-bottom: 10px;">
    <tr class="odd">
        <td align="right" width="150px"><%=LanguageUtility.GetLanguageText("MENU_TEXT", Session)%>:</td>
        <td class="b blue"><%=this._SelectedMenu.Text %></td>
    </tr>
    <tr class="even">
        <td align="right"><%=LanguageUtility.GetLanguageText("ACTIVE", Session)%>:</td>
        <td> <%=this._SelectedMenu.Active ? "<img src=\"resources/images/active.png\" />" : "<img src=\"resources/images/inactive.png\" />"%></td>
    </tr>
<%if (_IsAdminLogged) { %>
    <tr class="odd">
        <td align="right"><%=LanguageUtility.GetLanguageText("CONTENT_TYPE", Session)%>:</td>
        <td><%=this._SelectedMenu.LinkType == 1 ? LanguageUtility.GetLanguageText("VIEWTYPE_IMAGE") : (this._SelectedMenu.LinkType == 2 ? LanguageUtility.GetLanguageText("VIEWTYPE_LINK") : LanguageUtility.GetLanguageText("VIEWTYPE_TEXT"))%></td>
    </tr>
<%} %>
</table>
<div style="border: solid 1px #89F;padding: 5px;margin-bottom: 10px;">
    <div style="overflow: hidden;font-weight: bold; padding-left: 2px;">
        <span><%=LanguageUtility.GetLanguageText("TOTAL") %>: <span style="color: #E76300;"><%=_TotalItem %></span> <%=LanguageUtility.GetLanguageText("ITEMS") %>.</span> <%if (_TotalItem > 1) { %>
        <span><%=LanguageUtility.GetLanguageText("VIEW")%>: <span style="color: #E76300;"><%=(_PageNo - 1) * PAGE_SIZE + 1%> - <%= ((_PageNo - 1) * PAGE_SIZE + (_ContentList == null ? _AlbumList.Rows.Count : _ContentList.Rows.Count))%></span></span>
        <%} %>
    </div>
<%if (_PageCount > 1) { %>
    <div style="overflow: hidden; padding-top: 10px;">
        <div class="boxPaging">
            <div class="pagenum f-left">
                <ul>
                    <li><a class="first" href="<%=this._PageUrl + "page=1" %>">|&lt;&nbsp;Đầu</a></li>
                    <li><a class="pre" href="<%=this._PageUrl + "page=" + (this._PageNo <= 1 ? 1 : (this._PageNo - 1)) %>">&lt;</a></li>
                    <%
                        int startPage = _PageNo - 4;
                        if (startPage > _PageCount - 9)
                        {
                            startPage = _PageCount - 9;
                        }
                        if (startPage < 1)
                        {
                            startPage = 1;
                        }
                        for (int i = startPage; i <= _PageCount && i < (startPage + 10); i++)
                        {
                    %>
                    <li <%=(i == _PageNo ? "class=\"selected\"" : "") %>><a href="<%=this._PageUrl + "page=" + i.ToString() %>"><%=i %></a></li>
                    <%   
                        }
                    %>
                    <li><a class="next" href="<%=this._PageUrl + "page=" + (this._PageNo >= this._PageCount ? this._PageCount : (this._PageNo + 1)) %>">&gt;</a></li>
                    <li><a class="last" href="<%=this._PageUrl + "page=" + this._PageCount.ToString() %>">Cuối&nbsp;&gt;|</a></li>
                </ul>
            </div>
        </div>
    </div>
<%} %>
</div>
<%
int startNum = (_PageNo - 1) * PAGE_SIZE;
if(_SelectedMenu.LinkType != 1) { %>
<table border="1" cellpadding="0" cellspacing="0" class="grid" id="tbGrid">
    <tr>
        <th width="42px">#</th>
        <th><%=LanguageUtility.GetLanguageText("HEADER", Session)%></th>
        <th><%=LanguageUtility.GetLanguageText("INSERT_DATE", Session)%></th>
        <th><%=LanguageUtility.GetLanguageText("IS_DEFAULT", Session)%></th>
        <th><%=LanguageUtility.GetLanguageText("ACTIVE", Session)%></th>
        <th width="90px"><%=LanguageUtility.GetLanguageText("FUNCTIONS", Session)%></th>
    </tr>
    <%if (this._ContentList != null) for (int i = 0; i < this._ContentList.Rows.Count; i++) 
      {
          System.Data.DataRow row = this._ContentList.Rows[i]; %>
    <tr class="<%=(i%2==1?"even":"odd") %>">
        <td align="center"><%=i + 1 + startNum %></td>
        <td><%=row[CommonPageContent.HEADER__COLUMN_NAME] %></td>
        <td align="center"><%=((DateTime)row[CommonPageContent.INSERTDATE__COLUMN_NAME]).ToString("yyyy/MM/dd HH:mm") %></td>
        <td align="center"><%=((int)row[CommonPageContent.ISDEFAULT__COLUMN_NAME] == 1 ? "<img src=\"resources/images/active.png\" />" : "<img src=\"resources/images/inactive.png\" />")%></td>
        <td align="center"><%=((int)row[CommonPageContent.ACTIVE__COLUMN_NAME] == 1 ? "<img src=\"resources/images/active.png\" />" : "<img src=\"resources/images/inactive.png\" />")%></td>
        <td align="left">
            <ul class="icon" style="width: 112px;">
            <%if ((int)row[CommonPageContent.ISDEFAULT__COLUMN_NAME] == 1){ %>
                <li><a title="<%=LanguageUtility.GetLanguageText("UNSET_DEFAULT", Session)%>" href="?action=unsetdefaultcontent&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>&contentid=<%=row[CommonPageContent.ID__COLUMN_NAME] %>" class="icon inactivebn">&nbsp</a></li>
            <%} else { %>
                <li><a title="<%=LanguageUtility.GetLanguageText("SET_DEFAULT", Session)%>" href="?action=setdefaultcontent&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>&contentid=<%=row[CommonPageContent.ID__COLUMN_NAME] %>" class="icon activebn">&nbsp</a></li>
            <%} %><!--
                <li><a title="<%=LanguageUtility.GetLanguageText("MOVE_UP", Session)%>" href="?action=moveupcontent&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>&id=<%=row[CommonPageContent.ID__COLUMN_NAME] %>" class="icon ascbn">&nbsp</a></li>
                <li><a title="<%=LanguageUtility.GetLanguageText("MOVE_DOWN", Session)%>" href="?action=movedowncontent&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>&id=<%=row[CommonPageContent.ID__COLUMN_NAME] %>" class="icon descbn">&nbsp</a></li>-->
                <li><a title="<%=LanguageUtility.GetLanguageText("MOVE", Session)%>" href="?action=movecontent&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>&id=<%=row[CommonPageContent.ID__COLUMN_NAME] %>" class="icon movbn">&nbsp</a></li>
                <li><a title="<%=LanguageUtility.GetLanguageText("EDIT", Session)%>" href="?action=editcontent&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>&contentid=<%=row[CommonPageContent.ID__COLUMN_NAME] %>" class="icon editbn">&nbsp</a></li>
                <li><a title="<%=LanguageUtility.GetLanguageText("DELETE", Session)%>" href="?action=deletecontent&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>&contentid=<%=row[CommonPageContent.ID__COLUMN_NAME] %>" class="icon deletebn" onclick="javascript: return confirmDelete();">&nbsp</a></li>
            </ul>
        </td>
    </tr>
    <%} %>
</table>
<%} else if(_SelectedMenu.LinkType == 1) {%>
<table border="1" cellpadding="0" cellspacing="0" class="grid" id="tbGrid">
    <tr>
        <th width="42px">#</th>
        <th><%=LanguageUtility.GetLanguageText("NAME", Session)%></th>
        <th><%=LanguageUtility.GetLanguageText("PRESENTATIVE_IMAGE", Session)%></th>
        <th><%=LanguageUtility.GetLanguageText("IS_DEFAULT", Session)%></th>
        <th><%=LanguageUtility.GetLanguageText("ACTIVE", Session)%></th>
        <th width="42px"><%=LanguageUtility.GetLanguageText("EDIT", Session)%></th>
    </tr>
    <%if (this._AlbumList != null) for (int i = 0; i < this._AlbumList.Rows.Count; i++)
          {
              System.Data.DataRow row = this._AlbumList.Rows[i]; %>
    <tr class="<%=(i%2==1?"even":"odd") %>">
        <td align="center"><%=i + 1 + startNum %></td>
        <td align="left"><a href="?action=viewalbum&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>&id=<%=row[CommonAlbum.ID__COLUMN_NAME] %>"><b><%=row[CommonAlbum.ALBUMNAME__COLUMN_NAME] %></b></a></td>
        <td align="center"><%if (row[CommonAlbum.IMAGE__COLUMN_NAME].ToString().Length > 0) { %>
            <a href="../<%=row[CommonAlbum.IMAGEPATH__COLUMN_NAME].ToString() + row[CommonAlbum.IMAGE__COLUMN_NAME].ToString()%>" target="_blank">
                <img src="ImageProvider.aspx?imgurl=<%=Server.UrlEncode("/"+row[CommonAlbum.IMAGEPATH__COLUMN_NAME].ToString() + row[CommonAlbum.IMAGE__COLUMN_NAME].ToString())%>" alt="" style="max-width: 100px; max-height: 75px;" />
            </a><%} else {%>&nbsp;<%} %>
        </td>
        <td align="center"><%=((int)row[CommonAlbum.ISDEFAULT__COLUMN_NAME] == 1 ? "<img src=\"resources/images/active.png\" />" : "<img src=\"resources/images/inactive.png\" />")%></td>
        <td align="center"><%=((int)row[CommonAlbum.ACTIVE__COLUMN_NAME] == 1 ? "<img src=\"resources/images/active_l.png\"" : "<img src=\"resources/images/inactive_l.png\"")%></td>
        <td align="left">
            <ul class="icon" style="width: 112px;">
            <%if ((int)row[CommonAlbum.ISDEFAULT__COLUMN_NAME] == 1)
              { %>
                <li><a title="<%=LanguageUtility.GetLanguageText("UNSET_DEFAULT", Session)%>" href="?action=unsetdefaultalbum&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>&id=<%=row[CommonAlbum.ID__COLUMN_NAME] %>" class="icon inactivebn">&nbsp</a></li>
            <%} else { %>
                <li><a title="<%=LanguageUtility.GetLanguageText("SET_DEFAULT", Session)%>" href="?action=setdefaultalbum&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>&id=<%=row[CommonAlbum.ID__COLUMN_NAME] %>" class="icon activebn">&nbsp</a></li>
            <%} %>
                <li><a title="<%=LanguageUtility.GetLanguageText("EDIT", Session)%>" href="?action=editalbum&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>&id=<%=row[CommonAlbum.ID__COLUMN_NAME] %>" class="icon editbn">&nbsp</a></li>
                <li><a title="<%=LanguageUtility.GetLanguageText("DELETE", Session)%>" href="?action=delalbum&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=Request.QueryString["mnuid"] %>&id=<%=row[CommonAlbum.ID__COLUMN_NAME] %>" class="icon deletebn" onclick="javascript: return confirmDelete();">&nbsp</a></li><!--
                <li><a title="<%=LanguageUtility.GetLanguageText("MOVE_UP", Session)%>" href="?action=moveupalbum&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>&id=<%=row[CommonAlbum.ID__COLUMN_NAME] %>" class="icon ascbn">&nbsp</a></li>
                <li><a title="<%=LanguageUtility.GetLanguageText("MOVE_DOWN", Session)%>" href="?action=movedownalbum&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>&id=<%=row[CommonAlbum.ID__COLUMN_NAME] %>" class="icon descbn">&nbsp</a></li>-->
                <li><a title="<%=LanguageUtility.GetLanguageText("MOVE", Session)%>" href="?action=movealbum&g=<%=this.Request.QueryString["g"] %>&mnuid=<%=this.Request.QueryString["mnuid"] %>&id=<%=row[CommonAlbum.ID__COLUMN_NAME] %>" class="icon movbn">&nbsp</a></li>
            </ul>
        </td>
    </tr>
    <%} %>
</table>
<%} %>
<%} %>
<script type="text/javascript">
    function confirmDelete() {
        var msg = '<%=LanguageUtility.GetLanguageText("CONFIRM_DELETE", Session).Replace(Environment.NewLine, "<br />")%>';
        return confirm(msg.replace(/<br \/>/gi, "\r\n").replace(/<br\/>/gi, "\r\n"));
    }
</script>